﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class otros_evoltaDownload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string filename = Request.QueryString["filename"].ToString();
        if (filename.Length>0)
        {
            try
            {
                Response.Clear();
                Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", filename.Substring(filename.IndexOf("@")+1, filename.Length - filename.IndexOf("@")-1)));
                switch (Path.GetExtension(filename).ToLower())
                {
                    case ".jpg":
                        Response.ContentType = "image/jpg";
                        break;
                    case ".gif":
                        Response.ContentType = "image/gif";
                        break;
                    case ".png":
                        Response.ContentType = "image/png";
                        break;
                    case ".pdf":
                        Response.ContentType = "application/pdf";
                        break;
                }
                Response.WriteFile(Server.MapPath(Path.Combine("~/reportes/scanDocumentosCliente", filename)));
                Response.End();
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
    }
}
